package StudyCode.summary.jarfile;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ResourceIsEitherZipJarWarFile {
	public static void main(String[] argv) throws Exception {
		String resource = "E:/Copy/1.jar";
		System.out.println("是不是zip、jar 或 war 文件? " + isSupported(resource));
	}


	public static final String[] SUPPORTED_FILES = new String[]{".zip",
			".jar", ".war"};


	public static boolean isSupported(String resource) {
		int idx = resource.lastIndexOf('.');
		if (resource.length() == idx + 4) {
			for (int i = 0; i < SUPPORTED_FILES.length; i++) {
				if (resource.endsWith(SUPPORTED_FILES[i]))
					return true;
			}
		}
		return false;
	}
}
